"""
@author: zrp
@file: 2023-11-17作业.py
@time: 2023/11/18 15:33
"""
#作业：
# 1.统计出现次数最多的字符以及每个字符出现的次数都输出
#2.字符串压缩
#3.统计字符串中大写字母，小写字母，数字，其他字符出现的次数

#1.
str1 = input("please input something:")
str2 = ""
count = 0
str3 = " "
for i in str1:
    if i not in str2:
        str2 += i
for j in str2:
    count1 = str1.count(j)
    print(f"{j}出现的次数为{count1}")
    if count < count1:
        count = count1
        str3 = j
    elif count == count1:
        str3 +="," + j
print(f"其中{str3}出现的次数最多，共出现了{count}次")

#2
str4 = input("please input something:")
str4 += " "
str5 = ""
count2 = 0
for k in range(len(str4)-1):
    if str4[k] != str4[k+1]:
            count2+=1
            str5 += str4[k]+str(count2)
            count2 = 0
    else:
            count2 +=1
print(str5)

#3
str6 = input("please input your number:")
print(str6)
count3 = 0
count4 = 0
count5 = 0
count6 = 0
for h in str6.strip():
    if  h.isdigit():
        count3 += 1
    elif h.isupper():
        count4 += 1
    elif h.lower():
        count5 += 1
    else:
        count6 += 1
print(f"大写字母出现的次数为{count4},小写字母出现的次数为{count5},数字出现的次数为{count3},其他字符出现的次数为{count6}")
str6.count()